#include "fig_miniboss_hadiez.h"
#include "fig_enemybullet_master.h"
#include "fighter.h"

#include "num/rand.h"
#include "math/facing.h"



FIGMiniBossHadiez::FIGMiniBossHadiez(FIGEnemyCraft::ENEMY_TYPES EnemyType) : 
							FIGEnemyMiniBoss(										
										EnemyType
										)
{
	
	m_Accel = 1.0f;	
	m_MaxAttackCount = 6;
}





void			FIGMiniBossHadiez::OnShootStyle1()
{

	for( int j = 0; j < 3; j++)
	{
		for(int i = 0; i < 4; i++)
		{
												
			FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(i),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_YELLOW,
												FIGBullet::SHOOT_STYLES_SINGLE,
												180,		// degree
												j * 0.1f,
												false,
												NULL
          										);
		}
	}

	


	


}

void			FIGMiniBossHadiez::OnShootStyle2()
{
	for( int j = 0; j < 3; j++)
	{
		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(0),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_YELLOW,
												FIGBullet::SHOOT_STYLES_SINGLE,
												180 + 10,		// degree
												j * 0.1f,
												false,
												NULL
          										);	
		
		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(1),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_YELLOW,
												FIGBullet::SHOOT_STYLES_SINGLE,
												180 - 10,		// degree
												j * 0.1f,
												false,
												NULL
          										);	

		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(2),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_YELLOW,
												FIGBullet::SHOOT_STYLES_SINGLE,
												180 + 10,		// degree
												j * 0.1f,
												false,
												NULL
          										);

		FIGEnemyBulletMaster::Instance().Shoot(
												this,
												m_Bone.GetPosByWayPoint(3),
												FIGEnemyBulletMaster::BULLET_TYPE_LONG_YELLOW,
												FIGBullet::SHOOT_STYLES_SINGLE,
												180 - 10,		// degree
												j * 0.1f,
												false,
												NULL
          										);	
	}





}

void		FIGMiniBossHadiez::Tick_RotateBack(float dt)
{
	float Step = 180.0f * dt ;
	
    if(m_RotateBackDegree <= 180)
	{
		if(m_RotateBackClockWise)
			m_Rotation += Step;
		else
			m_Rotation -= Step;

		m_RotateCounter += Step;   

		if(m_Rotation > 360)
			m_Rotation -= 360;
		if(m_Rotation < 0)
			m_Rotation += 360;
	}

	
	if( m_RotateCounter >= m_RotateBackDegree )
		m_MiniBossState = MINIBOSS_STATE_GOBACK;

	
	GoForward(dt);
}

void		FIGMiniBossHadiez::Tick_GoBack(float dt)
{
	m_Speed += ( 1 * dt);
	GoForward(dt);
	
	if( m_Pos.x < -0.3f || m_Pos.y < 0 || m_Pos.x > 1.3f || m_Pos.y > 1)
		m_IsAlive = false;
}

void		FIGMiniBossHadiez::ReSpawn()
{
	FIGEnemyMiniBoss::ReSpawn();
	m_RotateCounter = 0;

	m_RotateBackDegree =  num::RAND32::Instance().RandFloat( 100,170);
	m_RotateBackClockWise = false;

	if(num::RAND32::Instance().RandInt(0,1) == 0)
	{
		m_RotateBackClockWise = true;
	}


}

